package com.rongc.client.freight.base.view.widget;

import android.content.Context;
import android.content.DialogInterface;
import android.text.InputType;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.flyco.dialog.widget.NormalDialog;
import com.rongc.client.core.utils.SystemUtil;
import com.rongc.client.freight.R;

/**
 * Created by Bruce on 2017/1/4.
 */
public class BaseInputDialog extends NormalDialog {

    EditText editText;
    public BaseInputDialog(Context context) {
        super(context);
        setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                SystemUtil.showSoftKeyboard(getContext(), (EditText) findViewById(R.id.et_pay));
            }
        });
    }

    @Override
    public View onCreateView() {
        super.onCreateView();
        mLlContainer.removeView(mTvContent);
        editText = new EditText(mContext);
        editText.setId(R.id.et_pay);
        editText.setBackgroundResource(R.drawable.universal_input_nor);
//        editText.setPadding(dp2px(10), dp2px(6), dp2px(10), dp2px(6));
        editText.setMaxEms(10);
        editText.setInputType(InputType.TYPE_CLASS_NUMBER);
        editText.setGravity(Gravity.CENTER);
        LinearLayout.LayoutParams ll =  new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        ll.setMargins(SystemUtil.dip2px(mContext,20),SystemUtil.dip2px(mContext,20),
                SystemUtil.dip2px(mContext,20),SystemUtil.dip2px(mContext,20));

        editText.setLayoutParams(ll);
        mLlContainer.addView(editText,2);
        return mLlContainer;
    }

    @Override
    public void setUiBeforShow() {
        style(STYLE_TWO);
        title("加价");
        btnNum(2);
        btnText(new String[]{"取消","确定"});
        btnTextColor(new int[]{mContext.getResources().getColor(R.color.universal_text_primary),
                mContext.getResources().getColor(R.color.universal_text_primary)});
        titleTextColor(mContext.getResources().getColor(R.color.universal_text_primary));
        titleLineColor(mContext.getResources().getColor(R.color.universal_text_primary));
        super.setUiBeforShow();
    }



    public String getPrice(){
        return editText.getText().toString();
    }
}
